<?php
/**
 * @Author: rocky
 * @Copyright: 广州拓冠科技 <http://my8m.com>
 * Date: 2019/8/29
 * Time: 11:41
 */


namespace app\shop\validate;


use app\common\validate\BaseValidate;

class OrderValidate extends BaseValidate
{
    protected $rule = [
        'car_ids' => 'requireIf:type,1',
        'store_id' => 'require',
        'subscribe_time|预约时间' => 'requireIf:type,1|checkTime',
        'pay_type|支付类型'=>'require|in:1,3,4'
    ];
    
    protected $messages = [
        'car_ids.require' => '请选择商品',
        'store_id.require' => '请选择门店'
    ];
    
    protected function checkTime($value,$rule,$data=[])
    {
        if (strtotime($value) <= time()){
            return '请选择正确的预约时间';
        }
        return true;
    }
}